package com.easidea.tim.flex.remote.report
{
	
	import com.easidea.tim.flex.Env;
	import com.easidea.tim.flex.event.CustomerEvent;
	import com.easidea.tim.flex.remote.BaseDao;
	
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	
	import net.digitalprimates.persistence.hibernate.rpc.HibernateRemoteObject;
	
	
	public class ReportDao extends BaseDao
	{
		private var _service:HibernateRemoteObject = new HibernateRemoteObject();
		private static var _instance:ReportDao;
		
		public static function getInstance():ReportDao{
			if( !_instance ){
				_instance = new ReportDao();
			}
			return _instance;
		}
		
		public function ReportDao()
		{
			_service.channelSet = this.buildChannelSet();
			_service.destination="reportService";	
			_service.concurrency = "last";
			_service.makeObjectsBindable = true;
			_service.showBusyCursor = true;	
		}

		/***********************  以下开始各报表所用的数据调用方法   *************************/
		
		/**
		 * 获取年度库存分析报告
		 */
		public function getStorageYearlyReport(year:int):void{
			_service.addEventListener(ResultEvent.RESULT,getStorageYearlyReportResult);
			_service.addEventListener(FaultEvent.FAULT,_Fault);
			_service.getStorageYearlyReport(year);
		}
	
		private function getStorageYearlyReportResult(e:ResultEvent):void{
			_service.removeEventListener(ResultEvent.RESULT,getStorageYearlyReportResult);
			Env.dispatchEvent(new CustomerEvent("getStorageYearlyReportSuccess",e.result));
		}

	}
}